#include<iostream>
using namespace std;

bool FindInPartiallySortedMatrix(int martix[][4], int cols, int rows, int number)
{
	bool find=false;
	if (martix!=NULL&&cols>0&&rows>0)
	{
		int row=0;
		int col=cols-1;
		while(row<rows&&col>=0)
		{
			if (martix[row][col]==number)
			{
				find=true;
				break;
			}
			else if (martix[row][col]>number)
			{
				col--;
			}
			else
			{
				row++;
			}
		}
	}
	return find;
}

//
//int main()
//{
//	int matrix[][4] = {{1, 2, 8, 9}, {2, 4, 9, 12}, {4, 7, 10, 13}, {6, 8, 11, 15}};
//	bool t=FindInPartiallySortedMatrix(matrix,4,4,12);
//	cout<<t<<endl;
//}